/**
 * @file makevector.h
 * @brief 该文件用于生成指定数目N的数组，并且可以控制其乱序程度
 * @version 0.1
 * @date 2022-11-25
 * 
 * @copyright Copyright (c) 2022
 * 
 */



#include<iostream>
#include<vector>
#include<cstdio>
#include<ctime>  //要调用time()，需要加入头文件< ctime >
//为了方便的使用我们可以用宏定义来替换 rand函数
//生成随机数种子
#define random_int_1(a,b)       (rand()% (b - a) + a )           //取得[a,b)的随机整数
#define random_int_2(a,b)       (rand() % (b-a))+ a + 1          //取得(a,b]的随机整数
#define random_double(RAND_MAX) (rand() / double(RAND_MAX))      //取得0～1之间的浮点数

using namespace std;
int N=20000;

class create_rand{
public:
vector<int> create_rand_int_number_include_a(int a, int b,int num)//取得[a,b)的随机整数
{
    vector<int> res;
    srand((int)time(0));  //利用系统时钟，产生不同的随机数种子,把0换成NULL也行
    for(int i = 1 ; i <= num; i++)
    {
        int number = random_int_1(a,b);
        //cout<<number<<" ";
        res.push_back(number);
    }
    return res;
}

vector<int> create_rand_int_number_include_b(int a, int b,int num)//取得(a,b]的随机整数
{
    vector<int> res;
    srand((int)time(0));
    for(int i = 1 ; i <= num; i++)
    {
        int number = random_int_2(a,b);
        //cout<<number<<" ";
        res.push_back(number);
    }
    return res;
}

vector<double> create_rand_double(int num)//取得0～1之间的浮点数
{
    vector<double> res;
    srand((int)time(0));
    for(int i = 1 ; i <= num; i++)
    {
        double number = random_double(RAND_MAX);
        //cout<<number<<" ";
        res.push_back(number);
    }
    return res;
}

};


void Test()
{
    create_rand obj;
    vector<int> res_int_include_a;
    vector<int> res_int_include_b;
    vector<double> res_double;
    res_int_include_a = obj.create_rand_int_number_include_a(5, 20, 10);
    res_int_include_b = obj.create_rand_int_number_include_b(5, 20, 10);
    res_double        = obj.create_rand_double(10);
    cout<<endl<<"取得(a,b]的随机整数"<<endl;
    for(auto it : res_int_include_a)
        cout<< it<<" ";
    cout<<endl<<"取得[a,b)的随机整数"<<endl;
    for(auto it : res_int_include_b)
        cout<< it<<" ";
    cout<<endl<<"取得0～1之间的浮点数"<<endl;
    for(auto it : res_double)
        cout<< it<<" ";

}


